<?php include template('header','common');?>
<link rel="stylesheet" type="text/css" href="{__ROOT__}template/default/statics/css/join.css?v={HD_VERSION}">
<script type="text/javascript" src="{__ROOT__}statics/js/haidao.validate.js?v={HD_VERSION}"></script>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=606c2c548c389a54407d3dd00e1fb089&plugin=AMap.Geolocation"></script>
<form class="padding-small" method="post" action='{url("joins",array("formhash"=>FORMHASH))}' name="checkmobile">
<div class="container">
	<div class="head">
		<img src="{$member['avatar']}" alt="">
	</div>
    <style>
	.item{ padding:7px 10px;}
	</style>
	<div class="content" style="margin-top:0;">
		<div class="list">
			<div class="item">
				<img src="{__ROOT__}template/default/statics/img/xue-sheng-xing-ming-.png" alt="">
				<input type="text" name="truename" value="{$member['truename']}" placeholder="请输入真是姓名">
			</div>
			<div class="item">
				<img src="{__ROOT__}template/default/statics/img/jia-zhang-dian-hua-.png" alt="">
				<input type="text" name="mobile" value="{$member['mobile']}" placeholder="请输入手机号码">
				<span class="code" id="sendCode">获取验证码</span>
			</div>
			<div class="item">
				<img src="{__ROOT__}template/default/statics/img/yan-zheng-ma-.png" alt="">
				<input type="text" name="vcode" placeholder="请输入验证码">
			</div>
			<div class="item">
				<img src="{__ROOT__}template/default/statics/img/shen-fen-zheng-.png" alt="">
				<input type="text" name="ident" value="{$member['ident']}" placeholder="身份证">
			</div>
			<div class="item">
				<img src="{__ROOT__}template/default/statics/img/xue-li-.png" alt="">
                <select name="educational">
                	<option value="小学">小学</option>
                    <option value="初中">初中</option>
                    <option value="中专">中专</option>
                    <option value="高中">高中</option>
                    <option value="大专">大专</option>
                    <option value="大专在读">大专在读</option>
                    <option value="本科">本科</option>
                    <option value="本科在读">本科在读</option>
                    <option value="研究生">研究生</option>
                    <option value="研究生在读">研究生在读</option>
                    <option value="博士">博士</option>
                    <option value="博士在读">博士在读</option>
                </select>
			</div>
			<div class="item">
				<img src="{__ROOT__}template/default/statics/img/shi-.png" alt="">
                <select name="isEngage">
                	<option value="">是否从事过教育行业</option>
                    <option value="是">是</option>
                    <option value="否">否</option>
                </select>
			</div>
			<div class="item">
				<img src="{SKIN_PATH}statics/img/di-qu-.png" alt="">
				<select name="city">
					<option value="">请选择所在区域</option>		
					<?php foreach($areas as $k => $v){?>
						<option value="{$v['area']}">{$v['area']}</option>
					<?php }?>		
				</select>
			</div>
			<div class="item">
				<img src="{SKIN_PATH}statics/img/xue-xiao-.png" alt="">
				<select name="school_id">
					<option value="">请选择学校</option>		
					<?php foreach($schools as $k => $v){?>
						<option value="{$v['id']}">{$v['name']}</option>
					<?php }?>		
				</select>
			</div>
		</div>
	</div>
    <div style="width:100%; color:#777; text-indent:30px; padding:10px 0; font-size:14px;">请提交简历到 recruit@anxinsz.com.cn</div>
	<div class="btn-view">
		<button class="btn" style="margin-top:20px;">提交审核</button>
	</div>
	
</div>
</form>
<script>
var resetmobile = $("form[name=checkmobile]").Validform({
	ajaxPost:true,
	beforeCheck:function(){
		if($("input[name=truename]").val() == ''){
			alerts('真实姓名不能为空');
			$("input[name=truename]").focus();
			return false;
		}
		
		if($("input[name=mobile]").val() == ''){
			alerts('手机号码不能为空');
			$("input[name=mobile]").focus();
			return false;
		}
		
		if($("input[name=vcode]").val() == ''){
			alerts('请输入验证码');
			$("input[name=vcode]").focus();
			return false;
		}
		
		if($("input[name=ident]").val() == ''){
			alerts('请输入身份证');
			$("input[name=ident]").focus();
			return false;
		}
		var reg = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
		if(!reg.test(ident)) {
			alerts("身份证格式不正确");
			return false;
		}
		if($("input[name=educational]").val() == ''){
			alerts('请输入学历');
			$("input[name=educational]").focus();
			return false;
		}
		
		if($("select[name=city]").val() == ''){
			alerts('请输入城市地区');
			$("select[name=city]").focus();
			return false;
		}
		
		if($("select[name=school_id]").val() == ''){
			alerts('请输入意向学校');
			$("select[name=school_id]").focus();
			return false;
		}
	},
	callback:function(ret){
		if(ret.status == 1){
			alerts(ret.message,1,ret.referer);
		}else{
			alerts(ret.message);
		}
	}		
});

$("#sendCode").on("click",function() {
	var mobj = $('input[name="mobile"]');
	var str = mobj.val();
	if(str.length!=0){
		var reg = /^(1(([35][0-9])|(47)|[7][0678]|[8][0123456789]))\d{8}$/;
		var r = str.match(reg);
		if(r==null){
			alerts('您输入的手机格式不正确!');
			mobj.focus();
			return false;
		}else{
			checkAndSend(str);
		}			
	}else{
		alerts('手机号不能为空');
		mobj.focus();
		return false;
	}
});

//检查验证
function checkAndSend(mobile,code){
	var ajaxurl="<?php echo url('school/index/checkansend')?>";
	$.post(ajaxurl,{'mobile':mobile},function(data){
	},'json');
	$("#vcode").removeAttr("readonly disabled");
	reget(60);
}

function reget(count){
	var mobj = $('input[name="mobile"]');
	var btn = $("#sendCode");
	var count = count;
	var resend = setInterval(function(){
		count--;
		if (count > 0){
			btn.text(count+"s后再试");
			mobj.attr('readonly',true);
			//$.cookie("captcha", count, {path: '/', expires: (1/86400)*count});
		}else {
			clearInterval(resend);
			mobj.removeAttr('disabled readonly');
			btn.text("重获验证码").removeAttr('disabled').css({'cursor':'','background':'#b6d75e'});
		}
	}, 1000);
	btn.attr('disabled',true).css({'cursor':'not-allowed','background':'#989898'});
}

$(document).ready(function () {
	mapObj = new AMap.Map('iCenter');
	mapObj.plugin('AMap.Geolocation', function () {
		geolocation = new AMap.Geolocation({
			enableHighAccuracy: true,//是否使用高精度定位，默认:true
			timeout: 10000,          //超过10秒后停止定位，默认：无穷大
			maximumAge: 0,           //定位结果缓存0毫秒，默认：0
			convert: true,           //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
		});
		mapObj.addControl(geolocation);
		geolocation.getCurrentPosition();
		AMap.event.addListener(geolocation, 'complete', function (res) {
			console.log(res.addressComponent.district);
			console.log(res)
			$(".address span").html(res.addressComponent.district);
			$("[name='city']").val(res.addressComponent.district);
			getSchool(res.addressComponent.district);
		});//返回定位信息
		// AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
	});
});

$("[name='city']").change(function(){
	getSchool($(this).val());
});
function getSchool(area){
	var ajaxurl="<?php echo url('school/index/getSchool')?>";
	var _html = '<option value="">请选择学校</option>';
	$.post(ajaxurl,{'area':area},function(data){
		var list = data.result;
		$.each(list, function(i, v) {
			 _html += '<option value="'+v.id+'">'+v.name+'</option>';
		});
		$("[name='school_id']").html(_html);
	},'json');
}
</script>
<?php include template('footer','common');?>